package com.example;

import java.util.Arrays;

public class ArrayForTest {

    public static void main(String[] args) {
        ArrayForTest arrayTestDemo = new ArrayForTest();
        arrayTestDemo.getCount();
        arrayTestDemo.testFor();
    }

    int[] arrNum = {2, 5, 6, 8, 10};
    String[] arrName = {"张三","里斯","王五"};

    void getCount() {
        System.err.println("~~~~~~~~~~~~~" + Arrays.toString(arrNum));
        // for 循环 针对数组的for循环
        for (int num : arrNum) {
            System.out.println("index" + "\t" + num);
        }

        for(String name:arrName){
            System.out.println("name=>s" + "\t" + name);
        }
    }

    // 简单for循环
    void testFor() {
        for (int i=0; i < 5; i++) {
            if(i==3){
                // 跳出循环
                break;
            }
            System.out.println("index=>i" + "\t" + i);
        }
    }

}
